0 CpxTRS
↳1 DependencyGraphProof (BOTH BOUNDS(ID, ID), 7 ms)
↳2 CpxTRS
↳3 NestedDefinedSymbolProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTRS
↳5 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳6 CpxWeightedTrs
↳7 InnermostUnusableRulesProof (BOTH BOUNDS(ID, ID), 0 ms)
↳8 CpxWeightedTrs
↳9 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳10 CpxTypedWeightedTrs
↳11 CompletionProof (UPPER BOUND(ID), 0 ms)
↳12 CpxTypedWeightedCompleteTrs
↳13 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳14 CpxRNTS
↳15 CompleteCoflocoProof (⇔, 141 ms)
↳16 BOUNDS(1, 1)
primes → sieve(from(s(s(0))))
from(X) → cons(X, n__from(s(X)))
head(cons(X, Y)) → X
tail(cons(X, Y)) → activate(Y)
if(true, X, Y) → activate(X)
if(false, X, Y) → activate(Y)
filter(s(s(X)), cons(Y, Z)) → if(divides(s(s(X)), Y), n__filter(s(s(X)), activate(Z)), n__cons(Y, n__filter(X, sieve(Y))))
sieve(cons(X, Y)) → cons(X, n__filter(X, sieve(activate(Y))))
from(X) → n__from(X)
filter(X1, X2) → n__filter(X1, X2)
cons(X1, X2) → n__cons(X1, X2)
activate(n__from(X)) → from(X)
activate(n__filter(X1, X2)) → filter(X1, X2)
activate(n__cons(X1, X2)) → cons(X1, X2)
activate(X) → X
filter(s(s(X)), cons(Y, Z)) → if(divides(s(s(X)), Y), n__filter(s(s(X)), activate(Z)), n__cons(Y, n__filter(X, sieve(Y))))
primes → sieve(from(s(s(0))))
if(true, X, Y) → activate(X)
activate(n__from(X)) → from(X)
activate(X) → X
cons(X1, X2) → n__cons(X1, X2)
activate(n__cons(X1, X2)) → cons(X1, X2)
from(X) → cons(X, n__from(s(X)))
filter(X1, X2) → n__filter(X1, X2)
if(false, X, Y) → activate(Y)
from(X) → n__from(X)
sieve(cons(X, Y)) → cons(X, n__filter(X, sieve(activate(Y))))
activate(n__filter(X1, X2)) → filter(X1, X2)
primes → sieve(from(s(s(0))))
from(X) → cons(X, n__from(s(X)))
filter(X1, X2) → n__filter(X1, X2)
if(false, X, Y) → activate(Y)
from(X) → n__from(X)
if(true, X, Y) → activate(X)
activate(n__from(X)) → from(X)
activate(X) → X
cons(X1, X2) → n__cons(X1, X2)
sieve(cons(X, Y)) → cons(X, n__filter(X, sieve(activate(Y))))
activate(n__cons(X1, X2)) → cons(X1, X2)
activate(n__filter(X1, X2)) → filter(X1, X2)
primes → sieve(from(s(s(0)))) [1]
from(X) → cons(X, n__from(s(X))) [1]
filter(X1, X2) → n__filter(X1, X2) [1]
if(false, X, Y) → activate(Y) [1]
from(X) → n__from(X) [1]
if(true, X, Y) → activate(X) [1]
activate(n__from(X)) → from(X) [1]
activate(X) → X [1]
cons(X1, X2) → n__cons(X1, X2) [1]
sieve(cons(X, Y)) → cons(X, n__filter(X, sieve(activate(Y)))) [1]
activate(n__cons(X1, X2)) → cons(X1, X2) [1]
activate(n__filter(X1, X2)) → filter(X1, X2) [1]
sieve(cons(X, Y)) → cons(X, n__filter(X, sieve(activate(Y)))) [1]
cons(X1, X2) → n__cons(X1, X2) [1]
primes → sieve(from(s(s(0)))) [1]
from(X) → cons(X, n__from(s(X))) [1]
filter(X1, X2) → n__filter(X1, X2) [1]
if(false, X, Y) → activate(Y) [1]
from(X) → n__from(X) [1]
if(true, X, Y) → activate(X) [1]
activate(n__from(X)) → from(X) [1]
activate(X) → X [1]
cons(X1, X2) → n__cons(X1, X2) [1]
activate(n__cons(X1, X2)) → cons(X1, X2) [1]
activate(n__filter(X1, X2)) → filter(X1, X2) [1]
primes → sieve(from(s(s(0)))) [1]
from(X) → cons(X, n__from(s(X))) [1]
filter(X1, X2) → n__filter(X1, X2) [1]
if(false, X, Y) → activate(Y) [1]
from(X) → n__from(X) [1]
if(true, X, Y) → activate(X) [1]
activate(n__from(X)) → from(X) [1]
activate(X) → X [1]
cons(X1, X2) → n__cons(X1, X2) [1]
activate(n__cons(X1, X2)) → cons(X1, X2) [1]
activate(n__filter(X1, X2)) → filter(X1, X2) [1]
primes :: sieve sieve :: n__from:n__filter:n__cons → sieve from :: 0:s → n__from:n__filter:n__cons s :: 0:s → 0:s 0 :: 0:s cons :: 0:s → n__from:n__filter:n__cons → n__from:n__filter:n__cons n__from :: 0:s → n__from:n__filter:n__cons filter :: a → b → n__from:n__filter:n__cons n__filter :: a → b → n__from:n__filter:n__cons if :: false:true → n__from:n__filter:n__cons → n__from:n__filter:n__cons → n__from:n__filter:n__cons false :: false:true activate :: n__from:n__filter:n__cons → n__from:n__filter:n__cons true :: false:true n__cons :: 0:s → n__from:n__filter:n__cons → n__from:n__filter:n__cons |
const, const1, const2, const3
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
0 => 0
false => 0
true => 1
const => 0
const1 => 0
const2 => 0
const3 => 0
activate(z) -{ 1 }→ X :|: X >= 0, z = X
activate(z) -{ 1 }→ from(X) :|: z = 1 + X, X >= 0
activate(z) -{ 1 }→ filter(X1, X2) :|: X1 >= 0, X2 >= 0, z = 1 + X1 + X2
activate(z) -{ 1 }→ cons(X1, X2) :|: X1 >= 0, X2 >= 0, z = 1 + X1 + X2
cons(z, z') -{ 1 }→ 1 + X1 + X2 :|: X1 >= 0, X2 >= 0, z = X1, z' = X2
filter(z, z') -{ 1 }→ 1 + X1 + X2 :|: X1 >= 0, X2 >= 0, z = X1, z' = X2
from(z) -{ 1 }→ cons(X, 1 + (1 + X)) :|: X >= 0, z = X
from(z) -{ 1 }→ 1 + X :|: X >= 0, z = X
if(z, z', z'') -{ 1 }→ activate(X) :|: z' = X, Y >= 0, z = 1, z'' = Y, X >= 0
if(z, z', z'') -{ 1 }→ activate(Y) :|: z' = X, Y >= 0, z'' = Y, X >= 0, z = 0
primes -{ 1 }→ 1 + from(1 + (1 + 0)) :|:
eq(start(V, V1, V2),0,[primes(Out)],[]). eq(start(V, V1, V2),0,[from(V, Out)],[V >= 0]). eq(start(V, V1, V2),0,[filter(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V2),0,[if(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]). eq(start(V, V1, V2),0,[activate(V, Out)],[V >= 0]). eq(start(V, V1, V2),0,[cons(V, V1, Out)],[V >= 0,V1 >= 0]). eq(primes(Out),1,[from(1 + (1 + 0), Ret1)],[Out = 1 + Ret1]). eq(from(V, Out),1,[cons(X3, 1 + (1 + X3), Ret)],[Out = Ret,X3 >= 0,V = X3]). eq(filter(V, V1, Out),1,[],[Out = 1 + X11 + X21,X11 >= 0,X21 >= 0,V = X11,V1 = X21]). eq(if(V, V1, V2, Out),1,[activate(Y1, Ret2)],[Out = Ret2,V1 = X4,Y1 >= 0,V2 = Y1,X4 >= 0,V = 0]). eq(from(V, Out),1,[],[Out = 1 + X5,X5 >= 0,V = X5]). eq(if(V, V1, V2, Out),1,[activate(X6, Ret3)],[Out = Ret3,V1 = X6,Y2 >= 0,V = 1,V2 = Y2,X6 >= 0]). eq(activate(V, Out),1,[from(X7, Ret4)],[Out = Ret4,V = 1 + X7,X7 >= 0]). eq(activate(V, Out),1,[],[Out = X8,X8 >= 0,V = X8]). eq(cons(V, V1, Out),1,[],[Out = 1 + X12 + X22,X12 >= 0,X22 >= 0,V = X12,V1 = X22]). eq(activate(V, Out),1,[cons(X13, X23, Ret5)],[Out = Ret5,X13 >= 0,X23 >= 0,V = 1 + X13 + X23]). eq(activate(V, Out),1,[filter(X14, X24, Ret6)],[Out = Ret6,X14 >= 0,X24 >= 0,V = 1 + X14 + X24]). input_output_vars(primes(Out),[],[Out]). input_output_vars(from(V,Out),[V],[Out]). input_output_vars(filter(V,V1,Out),[V,V1],[Out]). input_output_vars(if(V,V1,V2,Out),[V,V1,V2],[Out]). input_output_vars(activate(V,Out),[V],[Out]). input_output_vars(cons(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. non_recursive : [cons/3]
1. non_recursive : [filter/3]
2. non_recursive : [from/2]
3. non_recursive : [activate/2]
4. non_recursive : [if/4]
5. non_recursive : [primes/1]
6. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is completely evaluated into other SCCs
1. SCC is completely evaluated into other SCCs
2. SCC is partially evaluated into from/2
3. SCC is partially evaluated into activate/2
4. SCC is partially evaluated into if/4
5. SCC is completely evaluated into other SCCs
6. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations from/2
* CE 8 is refined into CE [14]
* CE 7 is refined into CE [15]
### Cost equations --> "Loop" of from/2
* CEs [14] --> Loop 8
* CEs [15] --> Loop 9
### Ranking functions of CR from(V,Out)
#### Partial ranking functions of CR from(V,Out)
### Specialization of cost equations activate/2
* CE 11 is refined into CE [16,17]
* CE 12 is refined into CE [18]
* CE 13 is refined into CE [19]
### Cost equations --> "Loop" of activate/2
* CEs [17] --> Loop 10
* CEs [16,18,19] --> Loop 11
### Ranking functions of CR activate(V,Out)
#### Partial ranking functions of CR activate(V,Out)
### Specialization of cost equations if/4
* CE 10 is refined into CE [20,21]
* CE 9 is refined into CE [22,23]
### Cost equations --> "Loop" of if/4
* CEs [21] --> Loop 12
* CEs [20] --> Loop 13
* CEs [23] --> Loop 14
* CEs [22] --> Loop 15
### Ranking functions of CR if(V,V1,V2,Out)
#### Partial ranking functions of CR if(V,V1,V2,Out)
### Specialization of cost equations start/3
* CE 2 is refined into CE [24,25]
* CE 3 is refined into CE [26,27]
* CE 4 is refined into CE [28]
* CE 5 is refined into CE [29,30,31,32]
* CE 6 is refined into CE [33,34]
### Cost equations --> "Loop" of start/3
* CEs [24,25,26,27,28,29,30,31,32,33,34] --> Loop 16
### Ranking functions of CR start(V,V1,V2)
#### Partial ranking functions of CR start(V,V1,V2)
Computing Bounds
=====================================
#### Cost of chains of from(V,Out):
* Chain [9]: 2
with precondition: [2*V+3=Out,V>=0]
* Chain [8]: 1
with precondition: [V+1=Out,V>=0]
#### Cost of chains of activate(V,Out):
* Chain [11]: 2
with precondition: [V=Out,V>=0]
* Chain [10]: 3
with precondition: [2*V+1=Out,V>=1]
#### Cost of chains of if(V,V1,V2,Out):
* Chain [15]: 3
with precondition: [V=0,V2=Out,V1>=0,V2>=0]
* Chain [14]: 4
with precondition: [V=0,2*V2+1=Out,V1>=0,V2>=1]
* Chain [13]: 3
with precondition: [V=1,V1=Out,V1>=0,V2>=0]
* Chain [12]: 4
with precondition: [V=1,2*V1+1=Out,V1>=1,V2>=0]
#### Cost of chains of start(V,V1,V2):
* Chain [16]: 4
with precondition: []
Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [16] with precondition: []
- Upper bound: 4
- Complexity: constant
### Maximum cost of start(V,V1,V2): 4
Asymptotic class: constant
* Total analysis performed in 88 ms.